<?php
/**
 * Created by PhpStorm.
 * User: liyu
 * Date: 2018/4/9
 * Time: 上午10:32
 */

namespace app\common\exception;


class StatusCode
{
    protected static $errorCode = [
        'success' => 10000,
        'params_error' => 10001,
        'db_error' => 10002,
        'login_name_exists' => 10003,
        'params_not_null' => 10004,
        'data_not_exists' => 10005,
        'data_exception' => 10006,
        'password_error' => 10007,
        'account_disenabled' => 10008,
        'login_error' => 10009,
        'login_invalid' => 10010,
        'org_name_exists' => 10011,
        'wg_area_name_exists' => 10012,
        'wg_device_name_exists' => 10013
    ];

    protected static $msg = [
        10000 => '成功',
        10001 => '参数错误',
        10002 => '数据库操作异常',
        10003 => '用户名已存在',
        10004 => '参数不能为空',
        10005 => '数据不存在',
        10006 => '数据异常',
        10007 => '密码错误',
        10008 => '账号不可用',
        10009 => '登陆错误',
        10010 => '登陆失效',
        10011 => '组织名已存在',
        10012 => '维果点位名重复',
        10013 => '维果设备号重复'
    ];

    public static function getError($key) {
        $errorCode = self::$errorCode;
        $msg = self::$msg;
        return [
            'code' => $errorCode[$key],
            'msg' => $msg[$errorCode[$key]]
        ];
    }
}